﻿@model IEnumerable<OSBLE.Models.Users.UserProfile>

@using OSBLE.Models

@{
    ViewBag.Title = "Administration";
}

<h2>
    User Administration
    @Helpers.CreateToolTip(ToolTips.AdminTitle) 
</h2>

@Html.ActionLink("Manage Schools", "Index", "School")

<table>
    <tr>
        <th>
            UserName
            @Helpers.CreateToolTip(ToolTips.AdminUserName) 
        </th>
        <th>
            School
            @Helpers.CreateToolTip(ToolTips.AdminUserSchool) 
        </th>
        <th>
            ID
            @Helpers.CreateToolTip(ToolTips.AdminUserID) 
        </th>
        <th>
            FirstName
            @Helpers.CreateToolTip(ToolTips.AdminUserFirstName) 
        </th>
        <th>
            LastName
            @Helpers.CreateToolTip(ToolTips.AdminUserLastName) 
        </th>
        <th>
            Admin
            @Helpers.CreateToolTip(ToolTips.AdminUserIsAdmin) 
        </th>
        <th>
            Course Creator
            @Helpers.CreateToolTip(ToolTips.AdminUserIsCourseCreator) 
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @if (item.UserName != null)
            {
                @Html.DisplayFor(modelItem => item.UserName)
            }
            else
            {
                <text><em>Pending</em></text>
            }
            
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.School.Name)
        </td>
        <td>
            @Helpers.DisplayLastFourID(item.Identification)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FirstName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LastName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.IsAdmin)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CanCreateCourses)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
            @Html.ActionLink("Details", "Details", new { id = item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id = item.ID }) |
            @Html.ActionLink("Impersonate", "Impersonate", new { id = item.ID }, new { onclick="return confirm('You are about to impersonate a user. You will need to sign back in with your account after completion.');" })
        </td>
    </tr>
}

</table>
